home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: HELP with array declaration
- Date: 29 Mar 1996 21:56:13 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4jiidtINNpab@keats.ugrad.cs.ubc.ca>
- References: <315C7F92.30E18DFD@learning.c.com>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <315C7F92.30E18DFD@learning.c.com>, Ed <ed@learning.c.com> wrote:
- >Hi,
- >
- >I don't know why the compiler (gcc) complains given this code:
- >
- >
- >...
- >...
- >#define STRING 81
- >
- >void sort_insert(char a[][STRING], unsigned int numdata) {
- >
- >...
- >...
- >
- >}
- >
- >
- >The compiler says that "two or more data types in declaration of
- >'sort_insert' "
-
- It means that somewhere before the ``void sort_insert'' you have some other
- type keyword. You may have missed a semicolon or something silly like that:
-
-
- int
-
- #define STRING 81
-
- void sort_insert(void)
-
- {
- }
-
-
- That will cause the same error. Why? Because there are two datatypes in the
- list of declaration specifiers for the function, namely ``int'' and ``void''.
-
- You might not make such a stupid error, but you might make this:
-
- struct foo {
- int bar;
- } /* NO SEMICOLON!! */
-
- #define STRING 81
-
- void sort_insert(...
-
-
- Now the compiler things you are trying to do this:
-
- struct foo { int bar; } void sort_insert(...)
-
- a function that returns both void and a struct foo. Two types in a declaration
- specifier list, that is utterly illegal. That's like saying ``int char x;''.
- You gotta drop the struct, drop the void, or put in a semicolon between the
- struct declaration and the void.
-
- >I'm new to 'C' and I don't see anything wrong with the above
- >declaration.
-
- It's not in the declaration but stuff that precedes it. Check for missing
- semicolons. Also check inside any headers that you may have #included.
- --
-
-